package com.dao;

import java.util.List;
import java.util.Map;

/**
 * @author fanxiao  2022/2/17
 * @since 1.0.0
 */
public abstract class AbstractDbOperations implements DbOperations {

	private DbParser parser;

	private DbParamConverter converter;

	public AbstractDbOperations(DbParser parser, DbParamConverter converter){
		this.parser = parser;
		this.converter = converter;
	}

	public <T> T querySingleObjectById(Class<T> clz) {
		Map<String, Object> result = querySingleObjectById();
		return parser.parse(result, clz);
	}

	public <T> int insert(T t){
		Object obj = converter.convert(t);
		if (obj instanceof Map){
			return insert((Map) obj);
		}
		return 0;
	}

}